﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Lamex.Library;
using Lamex.Base;
using System.IO;

namespace Lamex.mTube.UI
{
    public partial class frmTube_Packaging : frmBaseChild
    {
        public frmTube_Packaging()
        {
            InitializeComponent();
        }

        private void frmTube_Packaging_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            string sql = @"SELECT 完成日期,包装MO,订单数量,产品颜色,产品尺寸,物料描述 FROM Test_Tube_PackagingList";
            dt = BaseBuildSql.GetDataTableBySql(sql);
            gridControl1.DataSource = dt;

            AddDataToLayoutView();
        }

        private void AddDataToLayoutView()
        {
            string path = @"\\tx-fs8\tx-pdd\SJ\STD_PANEL_DWG\Summary\";

            List<object> list = new List<object>();
            list.Add(new { AppName = "I5FA081A", IconName = SaveImage(path + @"\I5FA081A.tif") });
            list.Add(new { AppName = "PA3M0010A", IconName = SaveImage(path + @"\PA3M0010A.tif") });

            list.Add(new { AppName = "PADM0009B", IconName = SaveImage(path + @"\PADM0009B.tif") });
            list.Add(new { AppName = "PA3M0012A", IconName = SaveImage(path + @"\PA3M0012A.tif") });
            list.Add(new { AppName = "PADM0010B", IconName = SaveImage(path + @"\PADM0010B.tif") });
            list.Add(new { AppName = "I5FA082B", IconName = SaveImage(path + @"\I5FA082B.tif") });

            list.Add(new { AppName = "I5FA129B", IconName = SaveImage(path + @"\I5FA129B.tif") });
            list.Add(new { AppName = "I5FA270A", IconName = SaveImage(path + @"\I5FA270A.tif") });
            list.Add(new { AppName = "I5FA091B", IconName = SaveImage(path + @"\I5FA091B.tif") });
            list.Add(new { AppName = "I5FA099B", IconName = SaveImage(path + @"\I5FA099B.tif") });

            list.Add(new { AppName = "I5FA086A", IconName = SaveImage(path + @"\I5FA086A.tif") });

            gridControl2.DataSource = list;

            //在设计模式下，选[LAYOUT]，右键调整图片显示字段的[BestFit]属性，即可卡片实现图片大小自适应

        }

        public byte[] SaveImage(String path)
        {
            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); //将图片以文件流的形式进行保存
            BinaryReader br = new BinaryReader(fs);
            byte[] imgBytesIn = br.ReadBytes((int)fs.Length); //将流读入到字节数组中
            return imgBytesIn;
        }
    }
}